"""
__author__ = 'loong'
"""
import codecs
import json
from baye import models_v1, models_v2
from baye import structures


BaseFields = [
    (1, 'version'),
    (1, 'period'),
    (1, 'king'),
    (2, 'year'),
    (1, 'look_enemy'),
    (1, 'look_movie'),
    (1, 'move_speed'),
    (1, 'month'),
    (1, 'map_x'),
    (1, 'map_y'),
    (1, 'cursor_x'),
    (1, 'cursor_y'),
]

OrderFields = [
    (1, 'id'),
    (1, 'person'),
    (1, 'city'),
    (1, 'object'),
    (2, 'arms'),
    (2, 'food'),
    (2, 'money'),
    (1, 'consume'),
    (1, 'time_count'),
]


class GameSaveFile:
    def __init__(self, dat, ishex):
        if ishex:
            self.dat = codecs.decode(dat, 'hex')
        else:
            self.dat = dat
        self.cursor = 0

    def read_struct(self, fields):
        try:
            return structures.read_struct(self.dat, self.cursor, fields)
        finally:
            self.cursor += structures.sizeof(fields)

    def read_bytes_array(self, count):
        tmp = self.read_struct([(count, '_', bytes)])
        return [i for i in tmp['_']]


class GameSaveParser:
    GOODS_MAX = 200
    ORDER_MAX = 200
    PERSON_MAX = 250
    FIGHT_ORDER_MAX = 30
    CITY_MAX = 38

    def __init__(self, sav0, sav1, ishex, version):
        self.sav0 = GameSaveFile(sav0, ishex)
        self.sav1 = GameSaveFile(sav1, ishex)
        if version == 1:
            self.models = models_v1
        elif version == 2:
            self.models = models_v2
        else:
            raise Exception("Unknown model version")

    def parse(self, lib=None):
        result = {}
        base_info = self.sav0.read_struct(BaseFields)
        version = base_info['version']
        if version < 0x80:
            self.GOODS_MAX = 33
        if version < 0x81:
            self.ORDER_MAX = 100
        if version < 0x82:
            self.PERSON_MAX = 250

        result.update(base_info)

        if lib:
            libPeopleArray = lib.periods[base_info['period']-1].people

        people = []
        for i in range(self.PERSON_MAX):
            if lib and i >= len(libPeopleArray):
                break
            pInfo = dict(self.sav0.read_struct(self.models.PERSON))
            if lib:
                pInfo.update(name=libPeopleArray[i].name)
            people.append(pInfo)

        result.update(people=people)

        v = self.sav0.read_bytes_array(self.PERSON_MAX)
        result.update(person_queue=v)

        v = self.sav0.read_bytes_array(self.GOODS_MAX)
        result.update(tool_queue=v)

        v = self.sav1.read_bytes_array(self.FIGHT_ORDER_MAX)
        result.update(fighters_ind=v)

        v = self.sav1.read_bytes_array(10*self.FIGHT_ORDER_MAX)
        result.update(fighters=v)

        orders = []
        for i in range(self.ORDER_MAX):
            order = self.sav1.read_struct(OrderFields)
            orders.append(dict(order))
        result.update(orders=orders)

        cities = []
        for i in range(self.CITY_MAX):
            city = self.sav1.read_struct(self.models.CITY)
            cities.append(dict(city))
        result.update(cities=cities)

        return result


def parse_sav(dat0, dat1, version):
    return GameSaveParser(dat0, dat1, ishex=True, version=version).parse()


if __name__ == '__main__':
    # for http://bgwp.gitee.io/baye
    sav0 = b"830105BE000101010100000100000101562464000064002003020033000201545A640300640020030000230003014946640400640220030000240004014E54640100640120030000230005015F51640400640020030E0B23000601592E640400640064000000220007012E416401006401200300003A0008013952640400640220030000250009014C356401006401200300002B000A013C3864040064012003000027000B011E1964040064012003000030000C012F2F64040064012003000028000D012F3E64040064006400000023000E01554C6403006400200305001D000F0116476404006402200300003000100134486404006402200300003A001101594B640400640020030A0025001201471F64000064012003000023001301454B6401006402200300001B000101365C590200640220030000280001016E355F0000640420030117220001015C17580400640020030000230001015D525B0400640220030000150001014C155701006403200300002A000101471C5700006403200300002C0001014B416101006401200300002200010149235803006402200300002000010146375703006400200300002300010154365703006400640000002800010134165A04006401200300001F000101105523040064022003000035000101295D260300640220030000210002015C3C5E0000640020030000210002015D306204006400200300001B0002014A5355030064012003000010000201522A5804006401200300001F000201503F5C000064022003000015000201494A5E0000640320030000160003015E376200006400200300001E0003015F305F00006400200300001D00030152285400006402200300002C0003013258550400640220030000250003013955560300640120030000220003011C5E6004006402200300001C000301155B5C04006402200300001A00030127525402006401200300002300040158315804006400200306002300040148284B01006401200300002100040151234E00006401640000002C0004014A185800006402200300002000050158535A04006401200300002700050153285E0400640320030000220005014C3F5D040064032003000024000501513D60040064022003000023000501603A6404006400640000002D0005014D5064040064016400000026000601463C5A03006400640000001B00060162356400006400640000001800060160145E0000640064000000170006013E1F5800006402640000002C0006014E28570000640164000000170006012D3356000064026400000016000601532853000064016400000016000601471D540000640164000000190006012D2658000064016400000019000601463F560000640064000000190006014638580000640264000000190007011F585703006402200300003A0007014556580300640020030000150007011E52570300640164000000170007013552530300640220030000190007014117580100640120030000150007013A35520400640020030000230008015D2B5804006400200300001800080139295700006401200300002300090123425804006401200300001E00090133325404006402200300001E000901392F4E040064012003000028000A0139504B030064022003000022000A014C1558000064012003000024000A01502656000064002003000022000B0133505804006402200300001A000B011C4A57040064012003000019000B0138295E040064002003000016000B01365060040064022003000016000C0149224E00006400200300001E000001335D56030064026400000024000D0165384B04006400640007001E000D0128385E04006401640000001E000E016A516204006401200303001C000E016B4362000064002003040017000F01145D58030064022003000023000F01354A4E010064012003000021000F014E3B55020064032003000023000F014E524C020064032003000024000F01462B5801006401200300002A000F015C315804006400200300001B001001564D580300640220030000150010015953560400640020030000250011014E2B5E04006400200300001E0011012C3B5704006402200300001A001101362054040064012003000018001101513A5204006401200300001B0012014D24640000640120030000120012014B35550000640220030000100013014D2D54040064002003000012001301144457010064012003000017001301293558040064022003000014001301384E4E03006402200300001B00000155430000006403640000001F000001483D0000006403640000001000000124580003006402640000002D000001315C000300640164000000170000012F2A0000006402640000001C00000153430000006401640000002C0000011C5F00040064026400000025000001215E00040064016400000031000001444E000400640364000000150000014B2D0004006401640000002A00000139530004006402640000001B000001154D0003006401640000001C000001345C0004006402640000002100000134540000006401640000001E0000013A48000300640164000000220000012662000300640264000000290000014D40000300640164000000210000011C6300030064026400000014000001294E0004006403200300001C0000012854000400640320030000160000012F460003006401200300002100000124590004006401640000003100000152380004006401640000002A00000125600003006401640000002B000001513800000064036400000016000001364F000300640164000000130000014E61000300640264000000280000014B3B000400640020030000120000016018000000640164000000140000012B5E0003006402640000001B000001275D0003006401640000002C0000013858000100640220030000140000014A4D00040064002003000012000001524C00040064002003000015000001523B000300640164000000180000014346000300640164000000170000011E580001006402640000002D0000011A570003006401200300001C0000014D460003006402640000001F000001532F000000640164000000290000014D3700000064006400000011000001393F0001006403640000002C000001224B0003006401640000002500000128560004006402640000002200000154380004006403640000001A00000148370004006403640000001A0000015B35000400640020030000140000011954000400640164000000100000011A64000400640164000000270000012450000100640164000000230000014A2C0000006401640000001E0000014D340004006403640000002B000001532D00040064026400000024000001365E000100640264000000270000015653000300640064000000150000014B21000000640364000000190000015C4500040064002003000017000001625700040064026400000016000001532E00040064012003000014000001474D0003006402640000001C0000015B3B0000006401640000002D0000012E480000006401640000002B0000011456000400640164000000120000014B54000400640364000000120000014D35000100640320030000260000013349000400640164000000160000013A4D000400640264000000160000012247000000640120030000170000012C4B00040064012003000017000001164D0000006403640000002A0000015D390000006402640000002A00000153360000006401200300001F0000013B29000000640364000000160000012F2900010064022003000026000001184A0000006401640000001E0000012E510003006401640000002D0000149696000400640420030000000000149696000400640520030000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640364000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000000000000000000000640064000000003839A11063646566A61167684093979EAF094E4F500D595A8FAC02262728292A2B2C2D95A2A3A407494A053A3C3D3E3F41420B557B849A1718191A0A5152535470868AB7012021222324256E7E89AE0643444612696A6B6C00131415161E1F7498084B4C4D9CAB47909948B5AD1B1D032E2F31758192A5800F616271B3B00E565B5C5D5EB85F6082B19B8D8EB9BA888CB40432333435857FB6A70C57580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001F20111E10141307080C0B0F1C171D151B180E12191A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    sav1 = b"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0006391514D30666191C073B3A98FD0700AD650200CA00B4010000000300000011115C158D058218020C2B382BA107006B36020055014B05000003060001001212930DE304C60E6E0427374B310300EA4601007E002005000009030101000641F906B8023808C7033A45514C0100B95900006B00AE0000000C050200000A0A1A12B2069D12E3064345CA2703001ADA0000C3009405000011040201000E0EA609AA03B6094D03443E38540100E17D00005D00D204000015050300000303C818290AE6166309442BCF1C0800A2F903000B01720600001A0D03000008082F1D020E151B4A0A2E3C38F90700D6DE020024016807000027030300000606D112E7078F1259082F33B21D03004FEF0000ED00F90100002A080300000C0CD3103906D61215053431CC2B0300E40B01009000760500003205030100011AA2212711F422451431270C740C00FD57080040023108000037040400000B0B7517520AD21DC00723250B0B0800B6690200DC007C0600003B0904000002024811D6041C13C704301E362803008BFA000087001D050000440B04020007075B17B507B21D640A32396E0B0800BE9E03002701D50500004F040600001313191C6D0870196909273209160800026D02000B010306000053050601000101B1259913F7222E122430104A0C00082506000502CE080000580907000009098914BF05E216FB0A353CFF0B0800997E020038015705000061060703000748F60693028207DA023E28486D01004766000051008C04000067030A020007493504EF01DB05A3013E3E8FB00100777000002E00630400006A020C000000000D0456017D0824033724CFB10100D18A000059003D0400006C010C0000011C6A121A08630F000437273412030069CC00007100EE0500006D020C000004041C0E83048F115F07422C00150300420C0100D100080500006F050C00000000A61B710C141E230E3D21671808009DC0020092010407000074030C01000000000DF0040B11D6072442B2170300021D0100DE002405000077010D00001010BD159B074F14BB0845351FE307005A350200F800CE05000078050D000000006510EB04E00EE8043B3F3F4E03008FD300008B00220500007D010D00000F0FEC15DD0964171F09254477160800C612030003015F0600007E070D00000F61E90B3D05510E95063C237F1D0300C5860100BB003705000085030D02000000210FFE049410A205382F065C03009B350100A0002705000088010F02000000190FC6031E10E5072C3F8D1F0300DA070100E000D904000089011101000000570F7204910D60062D3647560300D3080100B500040500008A04120000000032056302E70944032744005F0100425B00005C00800400008E021200000000B51105069C0F8E06303C5339030065730100BA006905000090011200000505C10B0D05CF0E97043B45B10E0300F111010082002B0500009106120000000008104006151334083E31612A030002EB0000E9007805000097021200000000F211FF06860C020544283B4A0300007B01008E00A705000099001202000000FB0D4A067E0D65052C3EEC3B030089DF000099007A05000099011402000000F31294079D0C2E0620287575030079500100AF00CD0500009A03160071D75E7C"
    result = parse_sav(sav0, sav1, 1)
    print(result)

    # for http://bgwp.gitee.io/baye-alpha
    sav0 = b"9301C8000500BE0001010101000001000000010005965A6400006404200302000000330000020005B49664030064042003000000002300000300087B64640400640220030000000024000004000882876401006401200300000000230000050005966E640400640420030E000B002300000600058C506404006404640000000000220000070008606E64010064012003000000003A000008000A5A8264040064052003000000002500000900087E6764010064012003000000002B00000A00086E6A64040064012003000000002700000B00085A4B64040064012003000000003000000C0008626264040064012003000000002800000D0008617064040064006400000000002300000E0008877E64030064002003050000001D00000F000848796404006402200300000000300000100008667A64040064022003000000003A00001100058C60640400640420030A00000025000012000879516400006401200300000000230000130008777D64010064022003000000001B000001000A69965902006405200300000000280000010005AA7D5F000064042003010017002200000100058C505804006404200300000000230000010008A0825B04006402200300000000150000010008825057010064032003000000002A00000100087D5257000064032003000000002C0000010008806E61010064012003000000002200000100087C5558030064022003000000002000000100087869570300640020030000000023000001000154365703006400640000000000280000010008664B5A040064012003000000001F000001000A4687230400640520030000000035000001000A5B8F26030064052003000000002100000200058E645E000064042003000000002100000200058F5062040064042003000000001B00000200087C855503006401200300000000100000020008847158040064012003000000001F000002000882715C000064022003000000001500000200087B7C5E00006403200300000000160000030005905F62000064042003000000001E000003000591585F000064002003000000001D0000030005845A54000064042003000000002C0000030008648A55040064022003000000002500000300086B87560300640120030000000022000003000A469060040064052003000000001C000003000A418C5C040064052003000000001A0000030008598454020064012003000000002300000400058A6358040064042003060000002300000400087A5A4B0100640120030000000021000004000883554E000064016400000000002C00000400087C4A58000064022003000000002000000500088A8C5A040064012003000000002700000500058C5A5E040064042003000000002200000500088C6E5D0400640320030000000024000005000883656004006402200300000000230000050005966264040064046400000000002D00000500014D50640400640164000000000026000006000578505A030064006400000000001B0000060005825A640000640464000000000018000006000876465E00006402640000000000170000060008643C58000064026400000000002C0000060008805057000064016400000000001700000600085064560000640264000000000016000006000887505300006401640000000000160000060008785054000064016400000000001900000600085F465800006401640000000000190000060008785A560000640064000000000019000006000878505800006402640000000000190000070008508057030064022003000000003A0000070008767D580300640020030000000015000007000A5084570300640564000000000017000007000867845303006402200300000000190000070008734958010064012003000000001500000700086C675204006400200300000000230000080005915F58040064042003000000001800000800086B5A5700006401200300000000230000090008557458040064012003000000001E0000090008656454040064022003000000001E00000900086B614E040064012003000000002800000A000A6B964B030064052003000000002200000A00087E4658000064012003000000002400000A0005855A56000064042003000000002200000B000A698458040064052003000000001A00000B0008507857040064012003000000001900000B00086A5A5E040064002003000000001600000B0008688260040064022003000000001600000C00087B554E000064002003000000001E0000000001335D56030064026400000000002400000D000165384B040064006400070000001E00000D00085A6A5E040064016400000000001E00000E0008A08262040064012003030000001C00000E0005A56462000064042003040000001700000F000A469658030064052003000000002300000F00058C624E010064042003000000002100000F0008806D55020064032003000000002300000F000A8C614C020064052003000000002400000F0008785F58010064012003000000002A00000F0005916258040064042003000000001B000010000596645803006404200300000000150000100005905F5604006404200300000000250000110008805F5E040064002003000000001E00001100085F5E57040064022003000000001A000011000868525404006401200300000000180000110008826C52040064012003000000001B00001200087F5664000064012003000000001200001200087D6755000064022003000000001000001300087F5F5404006400200300000000120000130008467657010064012003000000001700001300085B6758040064022003000000001400001300086A884E030064052003000000001B0000000001554300000064036400000000001F00000000087A6F0000006402640000000000100000000001245800030064026400000000002D0000000001315C00030064016400000000001700000000012F2A00000064026400000000001C0000000001534300000064016400000000002C00000000011C5F000400640264000000000025000000000855900004006401640000000000310000000008768000040064036400000000001500000000014B2D00040064016400000000002A0000000001395300040064026400000000001B0000000001154D00030064016400000000001C0000000001345C0004006402640000000000210000000008668600000064016400000000001E00000000013A480003006401640000000000220000000001266200030064026400000000002900000000014D4000030064016400000000002100000000011C630003006402640000000000140000000001294E00040064032003000000001C00000000085A8600040064032003000000001600000000086178000300640120030000000021000000000124590004006401640000000000310000000001523800040064016400000000002A0000000001256000030064016400000000002B000000000151380000006403640000000000160000000001364F0003006401640000000000130000000008809300030064026400000000002800000000087D6D0004006400200300000000120000000001601800000064016400000000001400000000012B5E00030064026400000000001B0000000001275D00030064016400000000002C0000000001385800010064022003000000001400000000014A4D0004006400200300000000120000000001524C0004006400200300000000150000000001523B0003006401640000000000180000000001434600030064016400000000001700000000011E5800010064026400000000002D00000000011A5700030064012003000000001C00000000087F7800030064026400000000001F0000000001532F00000064016400000000002900000000087F690000006400640000000000110000000001393F00010064036400000000002C0000000001224B000300640164000000000025000000000A5A920004006405640000000000220000000008866A00040064036400000000001A0000000001483700040064036400000000001A00000000015B350004006400200300000000140000000001195400040064016400000000001000000000011A640004006401640000000000270000000001245000010064016400000000002300000000014A2C00000064016400000000001E00000000014D3400040064036400000000002B0000000008855F0004006402640000000000240000000001365E0001006402640000000000270000000008887800030064006400000000001500000000014B2100000064036400000000001900000000015C450004006400200300000000170000000005BE820004006404640000000000160000000001532E0004006401200300000000140000000001474D00030064026400000000001C00000000015B3B00000064016400000000002D00000000012E4800000064016400000000002B0000000008468800040064016400000000001200000000087D8600040064036400000000001200000000014D35000100640320030000000026000000000133490004006401640000000000160000000008927F0004006402640000000000160000000001224700000064012003000000001700000000085E7D0004006401200300000000170000000001164D00000064036400000000002A00000000015D3900000064026400000000002A0000000001533600000064012003000000001F00000000086D5B00000064036400000000001600000000012F2900010064022003000000002600000000084A7C00000064016400000000001E0000000008789600030064016400000000002D0000000014C8C80004006404200300000000000000000014C8C80004006405200300000000000000000000000000000064006400000000000000000000000000000000640064000000000000000000000000000000006400640000000000000000000000000000000064006400000000000000000000000000000000640064000000000000000000000000000000006400640000000000000000000000000000000064006400000000000000000000000000000000640064000000000000000000000000000000006400640000000000000000000000000000000064006400000000000000000000000000000000640064000000000000000000000000000000006400640000000000000000000000000000000064006400000000000038003900A10010006300640065006600A6001100670068004000930097009E00AF0009004E004F0050000D0059005A008F00AC00020026002700280029002A002B002C002D009500A200A300A400070049004A0005003A003C003D003E003F00410042000B0055007B0084009A001700180019001A000A005100520053005400700086008A00B70001002000210022002300240025006E007E008900AE000600430044004600120069006A006B006C00000013001400150016001E001F007400980008004B004C004D009C00AB004700900099004800B500AD001B001D0003002E002F003100750081009200A50080000F00610062007100B300B0000E0056005B005C005D005E00B8005F0060008200B1009B008D008E00B900BA0088008C00B4000400320033003400350085007F00B600A7000C005700580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001F00200011001E00100014001300070008000C000B000F001C0017001D0015001B0018000E00120019001A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
    sav1 = b"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0006003A001514D30666191C073B3A98FD0700AD650200CA00B4010000000003000000000000110011005C158D058218020C2B382BA107006B36020055014B05000003000600000001000012001200930DE304C60E6E0427374B310300EA4601007E002005000009000300010001000006004100F906B8023808C7033A45514C0100B95900006B00AE0000000C00050002000000000A000A001A12B2069D12E3064345CA2703001ADA0000C300940500001100040002000100000E000E00A609AA03B6094D03443E38540100E17D00005D00D204000015000500030000000003000300C818290AE6166309442BCF1C0800A2F903000B01720600001A000D000300000000080008002F1D020E151B4A0A2E3C38F90700D6DE020024016807000027000300030000000006000600D112E7078F1259082F33B21D03004FEF0000ED00F90100002A00080003000000000C000C00D3103906D61215053431CC2B0300E40B010090007605000032000500030001000001001A00A2212711F422451431270C740C00FD5708004002310800003700040004000000000B000B007517520AD21DC00723250B0B0800B6690200DC007C0600003B0009000400000000020002004811D6041C13C704301E362803008BFA000087001D05000044000B000400020000070007005B17B507B21D640A32396E0B0800BE9E03002701D50500004F000400060000000013001300191C6D0870196909273209160800026D02000B010306000053000500060001000001000100B1259913F7222E122430104A0C00082506000502CE080000580009000700000000090009008914BF05E216FB0A353CFF0B0800997E020038015705000061000600070003000007004800F60693028207DA023E28486D01004766000051008C040000670003000A00020000070049003504EF01DB05A3013E3E8FB00100777000002E00630400006A0002000C00000000000000000D0456017D0824033724CFB10100D18A000059003D0400006C0001000C0000000001001C006A121A08630F000437273412030069CC00007100EE0500006D0002000C00000000040004001C0E83048F115F07422C00150300420C0100D100080500006F0005000C0000000000000000A61B710C141E230E3D21671808009DC00200920104070000740003000C0001000000000000000DF0040B11D6072442B2170300021D0100DE0024050000770001000D0000000010001000BD159B074F14BB0845351FE307005A350200F800CE050000780005000D00000000000000006510EB04E00EE8043B3F3F4E03008FD300008B00220500007D0001000D000000000F000F00EC15DD0964171F09254477160800C612030003015F0600007E0007000D000000000F006100E90B3D05510E95063C237F1D0300C5860100BB0037050000850003000D0002000000000000210FFE049410A205382F065C03009B350100A00027050000880001000F0002000000000000190FC6031E10E5072C3F8D1F0300DA070100E000D904000089000100110001000000000000570F7204910D60062D3647560300D3080100B500040500008A00040012000000000000000032056302E70944032744005F0100425B00005C00800400008E000200120000000000000000B51105069C0F8E06303C5339030065730100BA006905000090000100120000000005000500C10B0D05CF0E97043B45B10E0300F111010082002B0500009100060012000000000000000008104006151334083E31612A030002EB0000E9007805000097000200120000000000000000F211FF06860C020544283B4A0300007B01008E00A705000099000000120002000000000000FB0D4A067E0D65052C3EEC3B030089DF000099007A05000099000100140002000000000000F31294079D0C2E0620287575030079500100AF00CD0500009A000300160000009B259EEB"
    result = parse_sav(sav0, sav1, 2)
    print(result)


